import { Form } from 'ant-design-vue'
import { ref } from 'vue'

const { useForm } = Form

export function useRoleForm() {
  const show = ref(false)
  const loading = ref(false)
  const formModel = ref({
    roleName: '',
    roleKey: '',
    roleSort: 0,
    status: '0',
    menus: [],
    remark: ''
  } as ICreateRoleDTO)
  const formRules = ref({
    roleName: [{ required: true, message: '请输入角色名称' }],
    roleKey: [{ required: true, message: '请输入权限字符' }],
    roleSort: [{ required: true, message: '请输入角色顺序' }]
  } as FormRules<ICreateRoleDTO>)

  const formRef = useForm(formModel, formRules)

  return {
    show,
    loading,
    formModel,
    formRef
  }
}
